package com.xinbochuang.machine.admin.controller;


import com.xinbochuang.machine.admin.domain.Camera;
import com.xinbochuang.machine.admin.domain.Certification;
import com.xinbochuang.machine.admin.service.ICameraService;
import com.xinbochuang.machine.common.domain.TableDataInfo;
import com.xinbochuang.machine.framework.web.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.xinbochuang.machine.common.controller.BaseController;

/**
 *
 * @author 杜文博
 * @date 2020-10-28
 */
@RestController
@RequestMapping("/camera")
public class CameraController extends BaseController {

    @Autowired
    private ICameraService iCameraService;

    /**
     * 分页查询资质列表
     * @param camera
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo getCameraList(Camera camera){
        return  getDataTable(iCameraService.selectList(camera));
    }

    /**
     * 新增摄像头
     * @param camera
     * @return
     */
    @PostMapping("/insert")
    public AjaxResult insertCamera(@RequestBody Camera camera){
        return toAjax(iCameraService.insertCermera(camera));
    }

    /**
     * 修改摄像头信息
     * @param camera
     * @return
     */
    @PutMapping("/update")
    public AjaxResult updateCamera(@RequestBody Camera camera){
        return toAjax(iCameraService.updateCamera(camera));
    }

    /**
     * 批量删除资质
     * @param uuid
     * @return
     */
    @GetMapping("/delete")
    public AjaxResult deleteCamera(@RequestParam("uuid") String uuid){
        boolean result = iCameraService.deleteCamera(uuid);
        if(result){
            return toAjax(result);
        }else{
            return AjaxResult.ok("该工单不在待审核状态无法删除");
        }
    }

    /**
     * 摄像头是否启用
     *
     * @return
     */
    @PutMapping("/cameraUser")
    public AjaxResult cameraUser(@RequestBody Camera camera){
      return toAjax(iCameraService.cameraUser(camera));
    }

    /**
     * 摄像头是否预警
     *
     * @return
     */
    @PutMapping("/cameraWarning")
    public AjaxResult cameraWarning(@RequestBody Camera camera){
        return toAjax(iCameraService.cameraWarning(camera));
    }

    /**
     * 根据Id查询摄像头详情
     * @param uuId
     * @return
     */
    @GetMapping("/detail")
    public AjaxResult getCertificationList(@RequestParam("uuid") String uuId){
        return  AjaxResult.data(iCameraService.getDetail(uuId));
    }
}

